Attribute VB_Name = "modOptions"
Option Explicit

Type OptionsData
    FindQuotes As Boolean
    MIDI As Boolean
    Wav As Boolean
    Broadcasts As Boolean
    Windowed As Boolean
    LightingQuality As Byte
    Bit32 As Boolean
    HighPriority As Boolean
    DisablePlayerLights As Boolean
    DisableLighting As Boolean
    TimeStamp As Boolean
    RCLickMove As Boolean
    ChatLinks As Boolean
    ChatFilter As Boolean
    BChat As Boolean
    GlobalColor As Long
End Type

Public options As OptionsData

Sub SaveOptions()
    With options
        WriteString "Options", "Saved", "1"
        If .BChat = True Then
            WriteString "Options", "BChat", "1"
        Else
            WriteString "Options", "Bchat", "0"
        End If
        WriteString "Options", "GlobalColor", .GlobalColor
        If .ChatFilter = True Then
            WriteString "Options", "NoFilter", "0"
        Else
            WriteString "Options", "NoFilter", "1"
        End If
        If .MIDI = True Then
            WriteString "Options", "MIDI", "1"
        Else
            WriteString "Options", "MIDI", "0"
        End If
        If .ChatLinks = True Then
            WriteString "Options", "ChatLinks", "1"
        Else
            WriteString "Options", "ChatLinks", "0"
        End If
        If .Wav = True Then
            WriteString "Options", "Wav", "1"
        Else
            WriteString "Options", "Wav", "0"
        End If
        If .Broadcasts = True Then
            WriteString "Options", "Broadcasts", "1"
        Else
            WriteString "Options", "Broadcasts", "0"
        End If
        If .Windowed = True Then
            WriteString "Options", "Windowed", "1"
        Else
            WriteString "Options", "Windowed", "0"
        End If
        If .HighPriority = True Then
            WriteString "Options", "HighPriority", "1"
        Else
            WriteString "Options", "HighPriority", "0"
        End If
        If .DisablePlayerLights = True Then
            WriteString "Options", "DisablePlayerLights", "1"
        Else
            WriteString "Options", "DisablePlayerLights", "0"
        End If
        If .DisableLighting = True Then
            WriteString "Options", "DisableLighting", "1"
        Else
            WriteString "Options", "DisableLighting", "0"
        End If
        If .TimeStamp = True Then
            WriteString "Options", "TimeStamp", "1"
        Else
            WriteString "Options", "TimeStamp", "0"
        End If
        If .RCLickMove = True Then
            WriteString "Options", "RCLickMove", "1"
        Else
            WriteString "Options", "RCLickMove", "0"
        End If
        WriteString "Options", "LightingQuality", CStr(.LightingQuality)
        If Character.name <> "" Then
            Dim A As Long
            For A = 1 To 12
                WriteString Character.name, "Hotkey" + CStr(A), Character.Hotkey(A).Hotkey
                WriteString Character.name, "Hotkey" + CStr(A) + "Type", Character.Hotkey(A).Type
                WriteString Character.name, "Hotkey" + CStr(A) + "ScrollPosition", Character.Hotkey(A).ScrollPosition
            Next A
        End If
        If blnPlaying = True Then
            RedrawMap = True
        End If
    End With
End Sub
Sub LoadOptions()
    With options
        If ReadInt("Options", "Saved") = 1 Then
            
            If ReadInt("Options", "GlobalColor") > 0 Then
                .GlobalColor = ReadInt("Options", "GlobalColor")
            Else
                .GlobalColor = 2
            End If
            If ReadInt("Options", "MIDI") = 1 Then
                .MIDI = True
            Else
                .MIDI = False
            End If
            If ReadInt("Options", "NoFilter") = 1 Then
                .ChatFilter = False
            Else
                .ChatFilter = True
            End If
            If ReadInt("Options", "Wav") = 1 Then
                .Wav = True
            Else
                .Wav = False
            End If
            If ReadInt("Options", "ChatLinks") = 1 Then
                .ChatLinks = True
            Else
                .ChatLinks = False
            End If
            If ReadInt("Options", "Broadcasts") = 1 Then
                .Broadcasts = True
            Else
                .Broadcasts = False
            End If
            If ReadInt("Options", "Windowed") = 1 Then
                .Windowed = True
            Else
                .Windowed = False
            End If
            If ReadInt("Options", "HighPriority") = 1 Then
                .HighPriority = True
            Else
                .HighPriority = False
            End If
            If ReadInt("Options", "DisablePlayerLights") = 1 Then
                .DisablePlayerLights = True
            Else
                .DisablePlayerLights = False
            End If
            If ReadInt("Options", "BChat") = 1 Then
                .BChat = True
            Else
                .BChat = False
            End If
            If ReadInt("Options", "DisableLighting") = 1 Then
                .DisableLighting = True
            Else
                .DisableLighting = False
            End If
            If ReadInt("Options", "TimeStamp") = 1 Then
                .TimeStamp = True
            Else
                .TimeStamp = False
            End If
            If ReadInt("Options", "RClickMove") = 1 Then
                .RCLickMove = True
            Else
                .RCLickMove = False
            End If
            .LightingQuality = ReadInt("Options", "LightingQuality")

            If Character.name <> "" Then
                Dim A As Long
                For A = 1 To 12
                    Character.Hotkey(A).Hotkey = ReadInt(Character.name, "Hotkey" + CStr(A))
                    Character.Hotkey(A).Type = ReadInt(Character.name, "Hotkey" + CStr(A) + "Type")
                    Character.Hotkey(A).ScrollPosition = ReadInt(Character.name, "Hotkey" + CStr(A) + "ScrollPosition")
                Next A
            End If
            frmMain.TimeChatBox.Visible = False
            If options.TimeStamp = True Then
                frmMain.ChatBox.Visible = False
                frmMain.TimeChatBox.Visible = True
            End If
            If options.ChatLinks = True Then
                If options.TimeStamp = False Then
                    EnableURLDetect frmMain.ChatBox.hwnd, frmMain.hwnd
                Else
                    EnableURLDetect frmMain.TimeChatBox.hwnd, frmMain.hwnd
                End If
            Else
                DisableURLDetect
            End If
        Else
            .MIDI = True
            .Wav = True
            .Broadcasts = True
            .Windowed = True
            .LightingQuality = 1
            .HighPriority = False
            .DisablePlayerLights = False
            .DisableLighting = False
            SaveOptions
        End If
    End With
End Sub
